﻿using Microsoft.Xna.Framework;
using XNAProject.GameElements;

namespace XNAProject.PathFinder
{
    /// <summary>
    /// Represents one simplified searchtile, in our case this is a simplified version of
    /// the hexagon class with the A* properties
    /// </summary>
    public class searchNode
    //represents one hexagon in searchArea
    {
        //position
        public int posX { get; set; }
        public int posY { get; set; }

        //value to get here from neighbours
        public int AddedGCost { get; set; }

        //parent of this node
        public int parentNodeposX { get; set; }
        public int parentNodeposY { get; set; }

        //estimate to goal
        public int HCost { get; set; }

        //cost to move here
        public int GCost { get; set; }

        //lowest F is the most likely path
        public int Fcost { get; set; }

        //able to move here?
        public bool allowed { get; set; }

        //been here? serves as a closedlist for A*
        public bool washere { get; set; }

        public searchNode(Hexagon hexa)
        //constructor
        {
            //here we build up one tile for our searcharea
            posX = (int)hexa.position.X;
            posY = (int)hexa.position.Y;

            //score to move here
            AddedGCost = 10;

            //set parent to null
            parentNodeposX = 0;
            parentNodeposY = 0;

            //estimate will be calculated based on getEstimate later
            HCost = 0;

            //path cost up till this node
            GCost = 0;

            //Fcost init
            Fcost = 0;

            //allowed is based on hexa properties
            if (hexa.oilSpill || (hexa.shipOn && hexa.visible))
            {
                allowed = false;
            }
            else
            {
                allowed = true;
            }
            washere = false;
        }
    }
}
